package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.financing.wap.common.CommonConstantUtil;
import com.financing.wap.util.DTOdateSetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.financing.wap.dto.PrItemDTO;
import com.financing.wap.service.IPrItemService;
import com.financing.wap.dao.IPrItemDao;
/**
 * pr_item  
 * 项目表 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Service("prItemService")
public class PrItemServiceImpl implements IPrItemService{

	@Autowired
	private IPrItemDao prItemDao;

	@Override
	public int insert(PrItemDTO prItem) throws SQLException {
		DTOdateSetUtil.setCreateInfo(prItem);
		DTOdateSetUtil.setUpdateInfo(prItem);
		prItem.setDeleteTag(CommonConstantUtil.CommonStatus.DELETE_TAG_NORMAL);
		return prItemDao.insert(prItem);
	}

	@Override
	public void update(PrItemDTO prItem) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(prItem);
		prItemDao.update(prItem);
	}

	@Override
	public void updateForce(PrItemDTO prItem) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(prItem);
		prItemDao.updateForce(prItem);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		prItemDao.delete(id);
	}
	
	@Override
	public List<PrItemDTO> queryList(PrItemDTO prItem) throws SQLException {
		return prItemDao.queryList(prItem);
	}

	@Override
	public int queryListCount(PrItemDTO prItem) throws SQLException {
		return prItemDao.queryListCount(prItem);
	}

	@Override
	public PrItemDTO loadById(Integer id) throws SQLException {
		return prItemDao.loadById(id);
	}
 	@Override
	public PrItemDTO queryListGetFirst(PrItemDTO prItem)
			throws SQLException {
		 List<PrItemDTO> queryList = queryList(prItem);
		 if(queryList==null||queryList.size()==0){
			 return new PrItemDTO();
		 }
		 return queryList.get(0);
	}

	@Override
	public Map queryStatistics(String openId) throws SQLException {
		return prItemDao.queryStatistics(openId);
	}

	@Override
	public List<PrItemDTO> queryStatisticsList(String openId) throws SQLException {
		return prItemDao.queryStatisticsList(openId);
	}
}
